package com.cnbm.wcsbasic.protocol.netty.modbus.codec;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * 作者：蔡翔
 */
public class ModbusTcpChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        // Modbus
        // 在管道中添加我们自己的接收数据实现方法
        //todo 到时候这里改成  FixedLengthFrameDecoder  资料：https://www.cnblogs.com/java-chen-hao/p/11571229.html
//        channel.pipeline().addLast(
//                new LengthFieldBasedFrameDecoder(
//                200,
//                4,
//                2,
//                1,
//                7,
//                true)
//        );
        channel.pipeline().addLast(new ModbusTcpDecode());  //InBoundHandler
        channel.pipeline().addLast(new ModbusTcpEncode());  //OutBoundHandler
    }
}